﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MathTest {
    class Second {
        public static void getMaxAndMin() {
            int i = 0;
            int[] arry = new int[10];
            while (i < 4) {
                Console.WriteLine("请输入第" + (i + 1) + "个数：");
                arry[i] = int.Parse(Console.ReadLine());
                i++;
            }
            for (int m = 0; m <= 3; m++) {
                for (int n = 3; n > m; n--) {
                    int temp = arry[m];

                    if (arry[m] > arry[n]) {
                        arry[m] = arry[n];
                        arry[n] = temp;
                    }
                }
            }

            Console.WriteLine("最小的数为：" + arry[0] + "\t最大的数为：" + arry[3]);

        }


        public static void getStudentGrade() {
            Console.WriteLine("请输入成绩：");
            int number = int.Parse(Console.ReadLine());
            switch (number / 10) {
                case 9:
                case 10:
                    Console.WriteLine("成绩优秀");
                    break;
                case 8:
                    if ((number % 10) >= 5) {
                        Console.WriteLine("成绩优秀");

                    } else {
                        Console.WriteLine("成绩良好");
                    }
                    break;
                case 7:
                    if ((number % 10) >= 5) {
                        Console.WriteLine("成绩良好");

                    } else {
                        Console.WriteLine("成绩及格");
                    }
                    break;
                case 6:
                    Console.WriteLine("成绩及格");
                    break;
                default:
                    Console.WriteLine("成绩不及格");
                    break;

            }
        }

        public static void getTriangleArea() {
            int i = 0;
            double[] arry = new double[10];
            while (i < 3) {
                Console.WriteLine("请输入第" + (i + 1) + "条边：");
                arry[i] = double.Parse(Console.ReadLine());
                i++;
            }

            for (int m = 0; m <= 2; m++) {
                for (int n = 2; n > m; n--) {
                    double temp = arry[m];
                    if (arry[m] > arry[n]) {
                        arry[m] = arry[n];
                        arry[n] = temp;
                    }
                }
            }

            if ((arry[0] + arry[1]) > arry[2]) {
                double p = (arry[0] + arry[1] + arry[2]) / 2;
                double s = Math.Sqrt(p * (p - arry[0]) * (p - arry[1]) * (p - arry[2]));
                Console.WriteLine("三角形的面积为：" + s);
            } else {
                Console.WriteLine("很抱歉，该三条边无法构成三角形");
            }

        }

        public static void prinTriangle() {

            Console.WriteLine("请输入行数：");
            int n = Convert.ToInt32(Console.ReadLine());
            string row = "";
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= 2 * i - 1; j++) {
                    row += "*";
                }
                Console.SetCursorPosition((Console.WindowWidth - row.Length) / 2, i);
                Console.WriteLine(row);
                row = "";
            }
        }

        public static void prinDiamond() {
            Console.WriteLine("请输入要边长n：");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++) {

                for (int j = 1; j <= (n - i); j++) {
                    Console.Write(" ");
                }
                for (int m = 1; m <= ((2 * i) - 1); m++) {
                    Console.Write("*");
                }
                Console.WriteLine();
            }

            for (int p = 1; p <= (n - 1); p++)  {
                for (int j = 1; j <= p; j++) {
                    Console.Write(" ");
                }
                for (int m = 1; m <= (2*(n-p)-1); m++) {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
        }

    }
}
